import type { Meta, StoryObj } from "@storybook/react";
import { fn } from "@storybook/test";
import Alert, { AlertType } from "./Alert";
import "../../styles/index.scss";
import { library } from "@fortawesome/fontawesome-svg-core";
import { fas } from "@fortawesome/free-solid-svg-icons";
library.add(fas);
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
const meta = {
  title: "components/Alert",
  component: Alert,
  parameters: {
    // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
    layout: "centered",
  },
  // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
  tags: ["autodocs"],
  // More on argTypes: https://storybook.js.org/docs/api/argtypes
  argTypes: {
    type: {
      control: "radio",
      options: Object.values(AlertType),
      description: "类型",
    },
    message: { control: "text", description: "信息" },
    description: { control: "text", description: "描述" },
    closable: { control: "boolean", description: "关闭" },
  },
  // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
  args: { onClick: fn() },
} satisfies Meta<typeof Alert>;

export default meta;
type Story = StoryObj<typeof meta>;

export const DefaultAlert: Story = {
  args: {
    message: "message",
    description: "description",
  },
};

export const closeableAlert: Story = {
  args: {
    message: "message",
    description: "description",
    closable: true,
  },
};

export const DifferentType: Story = {
  render: () => (
    <>
      <Alert type={AlertType.Success} message="success" description="success" />
      <div style={{ height: "20px" }}></div>
      <Alert type={AlertType.Error} message="error" description="error" />
      <div style={{ height: "20px" }}></div>
      <Alert type={AlertType.Warning} message="warning" description="warning" />
      <div style={{ height: "20px" }}></div>
      <Alert type={AlertType.Info} message="Info" description="Info" />
      <div style={{ height: "20px" }}></div>
      <Alert type={AlertType.Danger} message="danger" description="danger" />
    </>
  ),
};
